-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor(project): improve typescript next/branch #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(project): improve typescript next/branch #62
Conversation
refactor(project): to ts: initial commit refactor(exercise-01): to ts refactor(exercise-02): to ts refactor(exercise-03): to ts refactor(exercise-04): to ts refactor(exercise-04): to ts: extra credit 01: prop getters refactor(exercise-05): to ts refactor(exercise-05): to ts: extra credit 01: default state reducer refactor(exercise-05): to ts: extra credit 02: state reducer action types refactor(exercise-06): to ts refactor(exercise-06): to ts: extra credit 01: add read only warning refactor(exercise-06): to ts: extra credit 02: add a controlled state warning refactor(exercise-06): to ts: extra credit 03: extract warnings to a custom hook refactor(exercise-06): to ts: extra credit 04: don’t warn in production
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just thinking about how this exercise should look in TypeScript and there are 2 ways that made the most sense to me:
- a) if we want
ToggleOn,ToggleOff, andToggleButtonto be "exported" with the optional props, then this line needs to be something likeReact.cloneElement(child, {on, toggle, ...child.props})to make the type signatures truthful - b) if we don't want to accept
onandtoggleprops (similar to the original version), then we need different types for the "exported" component than the actual implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, when I get around to this exercise, I think I'm going to do something like this: https://twitter.com/markdalgleish/status/1370951759284162565
Thanks again for this PR. I've finished my own changes to the next branch now :)
As for PR: https://github.com/kentcdodds/react-hooks/pull/112#issue-554331129
Story
AC:
./src/exercisesfolder with no consequences../src/final-ts/should be refactored to TypeScript.4.1. The codebase should remain as close as possible to @kentcdodds's initial implementation.
4.2. Should avoid distracting the user with complicated type signatures